package com.sat.ndk;

import android.content.Context;
import android.util.Log;
import android.widget.Toast;

/**
 * Project:Ndk
 * Package:com.sat.ndk
 * Created by 透野君爱打奶炮 on 2018-04-07 at 14:58
 */
public class JNI {
    // Used to load the 'native-lib' library on application startup.
    static {
        //System.loadLibrary("postArgs");
        System.loadLibrary("callback");
    }

    private Context mContext;
    public JNI(Context context){
        mContext = context;
    }

    /**
     * A native method that is implemented by the 'native-lib' native library,
     * which is packaged with this application.
     */
    public native int Add(int x,int y);
    public native String ChangeStr(String str);
    public native int[] arrIncrease(int[] array);


    public native void callbackVoid();
    public native void callbackVoidInt();
    public native void callbackVoidString();
    public native void callbackVoidToast();

    //C回调Java方法
    public void helloFromJava(){
        Log.d("TAG","哈哈哈，我是Java中的空方法");
    }

    public int add(int x,int y){
        return x+y;
    }

    public void printString(String s){
        Log.d("TAG","哈哈哈，"+s);
    }

    public void showToast(String s){
        Toast.makeText(mContext, s, Toast.LENGTH_SHORT).show();
    }
}
